package main

import (
	"fmt"
)

func main() {
	//go数组是值类型，传递为值传递，切片为引用传递
	var a [2]int
	var b [3]int
	fmt.Println(a) //[0 0]
	fmt.Println(b) //[0 0 0]

	c := [2]int{}
	fmt.Println(c) //[0 0]
	d := [2]int{1, 2}
	fmt.Println(d) //[1 2]
	e := [20]int{19: 1}
	fmt.Println(e) //[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]
	f := [...]int{1, 2, 3, 4, 5}
	fmt.Println(f) //[1 2 3 4 5]
	g := [...]int{0: 1, 1: 2, 2: 3}
	fmt.Println(g) //[1 2 3]
	//数组指针
	var h *[3]int = &g
	fmt.Println(h) //&[1 2 3]

	//指针数组
	x, y := 1, 2
	i := [...]*int{&x, &y}
	fmt.Println(i) //[0xc04203c240 0xc04203c248]

	//指向数组的指针
	j := new([10]int)
	fmt.Println(j) //&[0 0 0 0 0 0 0 0 0 0]

	k := [10]int{}
	k[1] = 3
	fmt.Println(k) //[0 3 0 0 0 0 0 0 0 0]

	l := new([10]int)
	l[1] = 3
	fmt.Println(l) //&[0 3 0 0 0 0 0 0 0 0]

	//多维数组
	m := [2][3]int{{1, 2, 3}, {2, 3, 4}}
	fmt.Println(m) //[[1 2 3] [2 3 4]]

	n := [...][3]int{{1: 1}, {2: 3}}
	fmt.Println(n) //[[0 1 0] [0 0 3]]
}
